<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
<script>
let getGuangdongCity = () => {
  let guangdongCity = [
    { name: 'shenzhen', id: 11 },
    { name: 'guangzhou', id: 12 },
  ];
  return guangdongCity;
}
let render = fn => {
  console.log('开始渲染广东省地图');
  document.write(JSON.stringify(fn()));
}
// render(getGuangdongCity)

let guangdongCity = {
  shenzhen: 11,
  guangzhou: 12,
  zhuhai: 13
}

let addressAdapter = oldAddressfn => {
  let address = {},
    oldAddress = oldAddressfn()
  for(let i = 0, c; c = oldAddress[i++]; ) {
    address[c.name] = c.id
  }
  return () => {
    return address
  }
}
render(addressAdapter(getGuangdongCity))

</script>
</body>
</html>